package com.xin.bi.mq;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.xin.bi.constant.MqConstant;

public class BiMqInit {
    public static void main(String[] args) throws Exception {
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost(MqConstant.HOST);
        connectionFactory.setUsername(MqConstant.username);
        connectionFactory.setPassword(MqConstant.password);
        Connection connection = connectionFactory.newConnection();
        Channel channel = connection.createChannel();
        channel.exchangeDeclare(MqConstant.BI_EXCHANGE_NAME,"direct");
        channel.queueDeclare(MqConstant.BI_QUEUE_NAME,true,false,false,null);
        channel.queueBind(MqConstant.BI_QUEUE_NAME,MqConstant.BI_EXCHANGE_NAME,MqConstant.BI_ROUTING_KEY);
    }
}
